package cn.jingyuan.swan.cloud.feign;

import feign.codec.Encoder;
import feign.form.spring.SpringFormEncoder;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.cloud.openfeign.support.SpringEncoder;
import org.springframework.context.annotation.Bean;

import javax.annotation.Resource;

public class FeignFormConfig {

    @Resource
    private ObjectFactory<HttpMessageConverters> messageConverters;

    /**
     * 配置 form 编码器，实现支持 form 表单提交
     *
     * @return FormEncoder
     */
    @Bean
    public Encoder feignFormEncoder() {
        return new SpringFormEncoder(new SpringEncoder(messageConverters));
    }

}
